<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            border: 1px solid red;
            width: 300px;
        }

        /* 解决高度塌陷 */
        div::after{
            content: "";
            display: block;
            clear: both;
        }

        p{
            /* 对子元素设置成浮动之后,导致父元素的高度会塌陷 */
            float: left;
        }
    </style>
</head>
<body>
    <div>
        <p>
            ppppppppppppppppp <br>
            pppppppppp
        </p>

        <p>
            ppppppppppppppppp <br>
            pppppppppp
        </p>
    </div>
</body>
</html>